#include <sgCore.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

using namespace std;

int main()
{	
	sgInitKernel();   
	//Polygon Ashape = new Polygon(new double[][]{ {0,10}, {1,10}, {3,7}, {8,7}, {9,10},{10,10},{5.5,0},{4.5,0}});
	//Polygon Ahole  = new Polygon(new double[][]{ {3,6}, {5,1}, {7,6}});

	sgCObject*   objcts[8];  
	sgC2DObject *firstCont, *secondCont, *bigCont;

	objcts[0] = sgCreateLine(0.0, 10.0, 0.0, 1.0, 10.0, 0.0);   
	objcts[1] = sgCreateLine(1.0, 10.0, 0.0, 3.0, 7.0, 0.0);  
	objcts[2] = sgCreateLine(3.0, 7.0, 0.0, 8.0, 7.0, 0.0);   
	objcts[3] = sgCreateLine(8.0, 7.0, 0.0, 9.0, 10.0, 0.0);   
	objcts[4] = sgCreateLine(9.0, 10.0, 0.0, 10.0, 10.0, 0.0);   
	objcts[5] = sgCreateLine(10.0, 10.0, 0.0, 5.5, 0.0, 0.0);   
	objcts[6] = sgCreateLine(5.5, 0.0, 0.0, 4.5, 0.0, 0.0);
	objcts[7] = sgCreateLine(4.5, 0.0, 0.0, 0.0, 10.0, 0.0);   
	bigCont = sgCContour::CreateContour(&objcts[0], 8);  	

	/*objcts[0] = sgCreateLine(3.0, 6.0, 0.0, 5.0, 1.0, 0.0);   
	objcts[1] = sgCreateLine(5.0, 1.0, 0.0, 7.0, 6.0, 0.0);   
	objcts[2] = sgCreateLine(7.0, 6.0, 0.0, 3.0, 6.0, 0.0);
	secondCont = sgCContour::CreateContour(&objcts[0], 4);  

	objcts[0] = firstCont;
	objcts[1] = secondCont;
	bigCont = sgCContour::CreateContour(&objcts[0], 2);*/

	sgCScene::GetScene()->AttachObject(bigCont);

	sgCContour *inset = reinterpret_cast<sgC2DObject*>(bigCont)->GetEquidistantContour(0.5, 0.5, true);

	sgCScene::GetScene()->AttachObject(inset);

	cout << inset->GetChildrenList()->GetCount() << endl;
	
	sgFreeKernel();
} 
